ccR.Rogue = {
	Moo = function() end,
}
setmetatable(ccR.Rogue, ccR)

ccR.Rogue.Feature = {
	Valid =
	function()
		--[[tblaura = { 158055, 172706, 172654, 172653, 164001, 160322 }
		local HasAura = false
		for x = 1, 40 do
			for i = 1, #tblaura do
				if ccR.Player.Has.Aura(tblaura[i]) then
					HasAura = true
				end
			end
		end]]

		if HasFullControl()
		and not ccR.Player.Is.Swimming()
		and not ccR.Player.Is.Falling()
		and not ccR.Player.Is.Flying()
		and not UnitOnTaxi("player")
		and not IsMounted()	
		and not ccR.Player.IsDead()
		and not UnitUsingVehicle("player")
		and not IsUsingVehicleControls()
		--and not HasAura
		and GetUnitSpeed("player") <= 20
		then 
			return true
		else
			return false
		end
	end,
	Auto_Stealth = 
	function()
		if ccR.Spell.Is.Ready(STEALTH)
		and HasFullControl()
		and GetNumLootItems() == 0
		and not ccR.Player.Has.Buff(STEALTH)
		and not ccR.Player.Is.InStealth()
		and not ccR.Player.Is.CastingOrChanneling()
		and (ccR.Var("Auto_Stealth_Resting") or (not ccR.Var("Auto_Stealth_Resting") and not IsResting()))
		and not UnitOnTaxi("player")
		and not IsMounted()	
		and not ccR.Player.Is.Dead()
		and not UnitUsingVehicle("player")
		and not IsUsingVehicleControls()
		and not vPauseStealth
		and GetUnitSpeed("player") < 20
		and not (not ccR.Player.Is.Moving() and UnitIsFriend("player", "target"))
		then
			ccR.Cast.Spell(STEALTH)
		end
	end,
	Auto_Burst_of_Speed =
	function()
		if ccR.Spell.Is.Ready(BURST_OF_SPEED) 
		and (not ccR.Player.Has.Buff(BURST_OF_SPEED) or ccR.Player.Buff.Duration(BURST_OF_SPEED) <= 0.5)
		and ccR.Player.Is.Moving()
		and (not ccR.Target.Exists() or (ccR.Target.Exists() and ccR.Target.Distance() >= 10)) 
		and ccR.Player.Energy() >= ccR.Var("Burst_of_Speed_Energy")
		and ccR.Rogue.Feature.Valid()
		and (
				(ccR.Player.Is.In.Stealth() and ccR.Var("ABOS_InStealth"))
				or
				(not ccR.Player.Is.In.Stealth() and ccR.Var("ABOS_OutOfStealth"))
			)
		then
			ccR.Cast.Spell(BURST_OF_SPEED)
		end
	end,
	Kick = function(time) if time == nil then time = 1 end if ccR.Target.Exists() and ccR.Target.Is.CastingOrChanneling() and ccR.Target.Is.Interuptable() and ccR.Spell.CanAttack(KICK) then if ccR.Target.Has.LeftOnCast(time) then ccR.Cast.Attack(KICK) end if ccR.Target.Is.Channeling() then ccR.Cast.Attack(KICK) end end	end,
	Recuperate = 
	function(health)
		if health == nil then health = 90 end
		if ccR.Spell.Is.Ready(RECUPERATE)
		and not ccR.Player.Has.Buff(RECUPERATE)
		and	ccR.Player.Combo_Points() >= 0
		and ccR.Player.Health() <= health
		and ccR.Rogue.Feature.Valid()
		and (
				(ccR.Var("AR_InCombat") and ccR.Player.Is.In.Combat())
				or
				(ccR.Var("AR_OutOfCombat") and not ccR.Player.Is.In.Combat())
			)
		then
			ccR.Cast.Spell(RECUPERATE)
		end
	end,
	Tricks_of_the_Trade = 
	function()
		if ccR.Spell.Is.Ready(TRICKS_OF_THE_TRADE) 
		and (ccR.Player.Is.In.Group() or ccR.Player.Is.In.Raid())
		and ccR.Player.Is.In.Combat()
		and ccR.Target.Is.Attackable()
		and not ccR.Player.Is.In.Stealth()
		then
			local vGroupType = nil
			local vTank = nil
			if ccR.Player.Is.InGroup() then vGroupType = "party" end;
			if ccR.Player.Is.InRaid() then vGroupType = "raid" end;
			if vGroupType == nil then return end
			local vPlayerCount = GetNumGroupMembers()
			for i = 0, vPlayerCount do
				vTank = vGroupType .. i
				if vTank ~= nil 
				and UnitGroupRolesAssigned(vTank) == "TANK" 
				and ccR.Spell.Is.InRange(TRICKS_OF_THE_TRADE, vTank)
				and ccR.Unit.Is.In.LineOfSight(vTank, "player")
				--and not ccR.Unit.Has.Buff(vTank, TRICKS_OF_THE_TRADE)
				--and not ccR.Unit.Has.Buff(vTank, 34477) -- Misdirection
				then 
					ccR.Cast.Spell(TRICKS_OF_THE_TRADE, vTank)
				end
			end
		end
	end,
}
setmetatable(ccR.Rogue.Feature, ccR.Rogue)